package com.sxw.springbootproducer.controller;


import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.web.bind.annotation.RequestMapping;

/*

        Channel: 代表 AMQP 0-9-1通道，并提供了大多数操作（协议方法）。
        Connection: 代表 AMQP 0-9-1 连接
        ConnectionFactory: 构建Connection实例
        Consumer: 代表消息的消费者
        DefaultConsumer: 消费者通用的基类
        BasicProperties: 消息的属性（元信息）
        BasicProperties.Builder: BasicProperties的构建器
* */
@RequestMapping("/rabbitmq")
public class RabbitmqController {



    //获取链接
    public Connection getConnection() throws Exception{
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("127.0.0.1");
        connectionFactory.setVirtualHost("/");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("admin");
        connectionFactory.setPassword("admin");
        Connection connection = connectionFactory.newConnection();
        return connection;
    }


    //




}
